import psutil
# 尝试读取CPU使用率
# cpus=psutil.cpu_percent(interval=1,percpu=True)
# print(cpus)
import time
from dao import cpuDao as cpuDao
def monitorCpu():
    while True:
        cpus = psutil.cpu_percent(interval=1, percpu=True)
        curTime=time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())

        cpuDao.saveToDb(curTime,cpus)

if __name__=="__main__":
    monitorCpu()